<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>使用 geolocation 对象</title>
</head>
<body>
<script>
    function success(position) {
        var crds = position.coords;
        var latiude = crds.latitude;
        var longitude = crds.longitude;
        var altitude = crds.altitude;
        var message = 'You\'re at ' + latiude + ', ' + longitude;
        alert(message);
    }
    function error(e) {
        alert(e.message);
    }
    navigator.geolocation.getCurrentPosition(success, error);
</script>
</body>
</html>